$(function () {
    //保存,继续
    $("body").on('click',"#save-role,.next_step",function () {//保存，并跳转下一步授权
        submitBasicInformation(true);
    }).on('click',"#save-role-back",function () {//保存返回
        submitBasicInformation(false);
    });
    /**
     * 保存角色信息
     */
    function submitBasicInformation(flag){
        var params = $("#role-fomr-data").serializeJSON();
        params = JSON.stringify(params);
        $.ajax({
            url: baseloaction + '/admin/manage/role/saveSysRole',
            data: params,
            dataType:'json',
            type:'post',
            contentType:'application/json;charset=utf-8',
            success:function (result) {
                if(result.success==false){
                    icModale(0,result.message);
                }else{
                    if(typeTo==1){
                        sessionStorage.newRoleName=result.entity.roleName;
                        sessionStorage.newRoleId=result.entity.id;
                    }
                    if(flag){
                        window.location.href=baseloaction + '/admin/manage/role/initRoleFunction?type='+typeTo+'&roleId='+result.entity.id;
                    }else{
                        window.location.href=baseloaction +"/admin/manage/role/listSysRole";
                    }
                }
            },
            error:function (error) {
                icModale(0,'系统错误，保存角色信息失败');
            }
    });
    }
});